(() => {
  function fac (arr, value) {
    let l = 0, r = arr.length - 1;
    while (l < r) {
      let mid = Math.floor(l + r / 2);
      if (arr[mid] === value) {
        return mid;
      } else if (value > arr[mid]) {
        l = mid + 1;
      } else if (value < arr[mid]) {
        r = mid - 1;
      }
    }
  }

  console.log('二分查找', fac([1, 3, 5, 8], 8));
})();